#ifndef QAUDIOSINK_H
#define QAUDIOSINK_H

#include <QObject>
#include <QIODevice>
#include <QString>
#include "modules/pulse.h"
#include "audioformat.h"

class AudioSink : public QObject
{
    Q_OBJECT
public:
    enum Mode {
        Invalid = -1,
        Speakers = 0, //this is the old interface, will be deleted asap
        Device = 1,
        Tcp = 2,
        Mute = 3,
        PulseAudio = 4,
        Native = 5,
        Phonon = 6,
        Alsa = 7,
        Udp = 8
    };
    struct userConfig {
        int channels;
        int sampleRate;
        int sampleSize;
        AudioFormat* format;

        AudioSink::Mode outputMode;
        int deviceId;
        struct TcpConfig {
            QString host;
            int port;
        };
        TcpConfig tcpConfig;
        QString sinkName;
#ifdef PULSE
        bool usePulse;
#endif
    };

    explicit AudioSink(const QString sinkName,AudioSink::userConfig userConfig,QObject *parent = 0);
     ~AudioSink();
    void sinkStream(QByteArray *sinkStream);
    void setFormat(AudioFormat newFormat);
    void setTargetDevice(QIODevice *targetDevice);
    bool isReady();
    QIODevice *getDevice();
    static Mode getModeFromString(QString modeName);
    static Mode getDefaultModule();

private:
    AudioFormat *format;
    QIODevice *devOut;
    Mode currentMode;
    void say(QString message);

signals:

public slots:

};

#endif // QAUDIOSINK_H
